export default {
  namespaced: true,
  state: {
    searchStates: {}
  },
  mutations: {
    SAVE_SEARCH_STATE(state, { path, params }) {
      state.searchStates[path] = params
    },
    CLEAR_SEARCH_STATE(state, path) {
      delete state.searchStates[path]
    }
  },
  actions: {
    saveSearchState({ commit }, { path, params }) {
      commit('SAVE_SEARCH_STATE', { path, params })
    },
    clearSearchState({ commit }, path) {
      commit('CLEAR_SEARCH_STATE', path)
    }
  },
  getters: {
    getSearchState: state => path => {
      return state.searchStates[path] || null
    }
  }
}